//http://www.cppblog.com/Files/dyj057/inifile.zip

#ifndef _CLOGGER_H_
#define _CLOGGER_H_
#include <stdio.h>
#include <iostream> //流类
#include <string>
#include <vector>
#include <stdarg.h>  // va_list  va_start
#include <time.h>
#include <fcntl.h>

#ifdef   _WINDOWS
#define snprintf _snprintf
#else
#include <unistd.h>
#endif

using namespace std;

enum Level
{
	LOG_NONE = 0, LOG_DATA, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG
};

enum Mode
{
	LOG_MODE = 0, MODE_FILE, MODE_CONSOLE, MODE_ALL
};

class CLogger
{
	public:
		CLogger();
		virtual ~CLogger();
	public:
		char *getTime();
		void setLogFile(const char *filename);
		void setLogLevel(const std::string strlevel);
		void setLogMode(const std::string logmode);
		void debug(const char *format, ...);
		void info(const char *format, ...);
		void warn(const char *format, ...);
		void error(const char *format, ...);

		void log(const char *format, ...);
		void data(const char *format, ...);

	private:
		Level logLevel;
		Mode logMode;
		char *strtime;
		char *buf;
		FILE *fp;
};
#endif
